package com.mbc.controller;


import com.mbc.comment.Result;
import com.mbc.dto.DetailsActivityInfoDTO;
import com.mbc.dto.InserTLoveBaseActivityDTO;
import com.mbc.service.LoveBaseActivityService;
import com.mbc.vo.DetailsActivityInfoVO;
import com.mbc.vo.SimpleActivityVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * <p>
 * 爱心基地活动表 前端控制器
 * </p>
 *
 * @author suimeng
 * @since 2024-04-19
 */
@RestController
@RequestMapping("/loveBaseActivity")
@Api(tags = "爱心基地活动接口")
@CrossOrigin
public class LoveBaseActivityController {

    @Autowired
    private LoveBaseActivityService loveBaseActivityService;

    /**
     * 新增爱心基地活动
     *
     * @param userId                    用户 ID
     * @param inserTLoveBaseActivityDTO inser tlove base 活动 DTO
     * @return {@link Result}<{@link Boolean}>
     */
    @PostMapping("/insert/{userId}")
    @ApiOperation("新增爱心基地活动")
    public Result<Boolean> insertLoveActivity(@PathVariable Integer userId,
                                              @RequestBody InserTLoveBaseActivityDTO inserTLoveBaseActivityDTO) {
        return Result.success(loveBaseActivityService.insertLoveActivity(userId, inserTLoveBaseActivityDTO));
    }

    /**
     * 分页查询所有活动
     *
     * @return {@link Result}<{@link ArrayList}<{@link SimpleActivityVO}>>
     */
    @GetMapping("/simpleActivity")
    @ApiOperation("分页查询所有活动")
    public Result<ArrayList<SimpleActivityVO>> getBySimpleActivity(@RequestParam Integer page,
                                                                   @RequestParam Integer size) {
        ArrayList<SimpleActivityVO> list = loveBaseActivityService.getBySimpleActivity(page, size);
        return Result.success(list);
    }

    /**
     * 根据活动id或名称查询爱心基地活动信息
     *
     * @param detailsActivityInfoDTO 详细信息 活动信息 DTO
     * @return {@link Result}<{@link ArrayList}<{@link SimpleActivityVO}>>
     */
    @GetMapping("/detailsActivityInfo")
    @ApiOperation("根据活动id或名称查询爱心基地活动信息")
    public Result<ArrayList<SimpleActivityVO>> getByIdSimpleActivity(DetailsActivityInfoDTO detailsActivityInfoDTO) {
        ArrayList<SimpleActivityVO> list =
                loveBaseActivityService.getByIdSimpleActivity(detailsActivityInfoDTO);
        return Result.success(list);
    }

    /**
     * 根据活动id查询爱心基地活动详细信息
     *
     * @param activityId 活动 ID
     * @return {@link Result}<{@link DetailsActivityInfoVO}>
     */
    @GetMapping("/detailsActivityInfo/{activityId}")
    @ApiOperation("根据活动id查询爱心基地活动详细信息")
    public Result<DetailsActivityInfoVO> getDetailsActivityInfo(@PathVariable Integer activityId) {
        DetailsActivityInfoVO detailsActivityInfoVO =
                loveBaseActivityService.getDetailsActivityInfo(activityId);
        return Result.success(detailsActivityInfoVO);
    }

    /**
     * 更新爱心活动浏览量
     *
     * @param activityId 活动 ID
     * @return {@link Result}<{@link Boolean}>
     */
    @PostMapping("/updateView/{activityId}")
    @ApiOperation("更新爱心活动浏览量")
    public Result<Boolean> updateViewNumber(@PathVariable Integer activityId) {
        return Result.success(loveBaseActivityService.updateViewNumber(activityId));
    }

    /**
     * 更新爱心活动点赞量
     *
     * @param activityId 活动 ID
     * @return {@link Result}<{@link Boolean}>
     */
    @PostMapping("/likesNumber/{activityId}")
    @ApiOperation("更新爱心活动点赞量")
    public Result<Boolean> updateLikesNumber(@PathVariable Integer activityId) {
        return Result.success(loveBaseActivityService.updateLikesNumber(activityId));
    }

    /**
     * 更新爱心活动参与人数
     *
     * @param activityId 活动 ID
     * @return {@link Result}<{@link Boolean}>
     */
    @PostMapping("/participationNumber/{activityId}")
    @ApiOperation("更新爱心活动参与人数")
    public Result<Boolean> updateParticipationNumber(@PathVariable Integer activityId) {
        return Result.success(loveBaseActivityService.updateParticipationNumber(activityId));
    }
}
